//#include "FactoryControlSystemTest.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "FactoryControlSystemAgent.h"
#include "Kit.h"
#include "KitMock.h"
#include "KitRecipe.h"
#include "ConveyorAgentMock.h"
#include <string>
#include <iostream>

class FactoryControlSystemAgent;
class Kit;
class KitRecipe;

std::string FCSTest="FCS Test";

class FactoryControlSystemTest : public ::testing::Test
{
public:

	FactoryControlSystemAgent fcs;

	FactoryControlSystemTest()
		: fcs(FCSTest)
	{
	}

	virtual void SetUp()
	{
	}
};

TEST_F(FactoryControlSystemTest, initializationTest)
{
	// There should be no kits in list of kits
	EXPECT_EQ(0, fcs.getKits()->size());

	// There should be no KitRecipes in list
	EXPECT_EQ(0, fcs.getKitRecipes()->size());

	// Pick and Execute an Action should return false because nothing is in the scheduler
	EXPECT_FALSE(fcs.pickAndExecuteAnAction());
}

TEST_F(FactoryControlSystemTest, msgHereIsKitOrder)
{
	//KitMock *kit = new KitMock();
	KitRecipe* kit = new KitRecipe();
	int numKits = 1;
	
	//ConveyorAgentMock conveyor ();
	ConveyorAgentMock *conveyor = new ConveyorAgentMock();
	fcs.setConveyor(conveyor);
	
	// Pick and Execute an Action should return false because there are no kits in its list of kits
	EXPECT_FALSE(fcs.pickAndExecuteAnAction());
	
	// Send FCS a kit order
	fcs.msgHereIsKitOrder(kit);

	// List of KitRecipes should have one kitRecipe
	EXPECT_EQ(numKits, fcs.getKitRecipes()->size());

	// FCS should send msgHereAreKits to conveyor once the fcs's scheduler is called
	EXPECT_CALL( (*conveyor), msgHereAreKits(kit));

	// Pick and Execute an Action should return true now that there is a NEW kit
	EXPECT_TRUE(fcs.pickAndExecuteAnAction());

	// Now FCS should not have any KitRecipes
	EXPECT_EQ(numKits - 1, fcs.getKitRecipes()->size());

	// Pick and Execute an Action should return false now because their are no more KitRecipes
	EXPECT_FALSE(fcs.pickAndExecuteAnAction());
}

TEST_F(FactoryControlSystemTest, msgHereIsFinishedKit)
{
	// Getting ready for test
	KitMock* kit = new KitMock();
	KitRecipe kitRecipe;
	int numKits = 5;
	
	ConveyorAgentMock* conveyor = new ConveyorAgentMock();
	fcs.setConveyor(conveyor);

	// Tell FCS that the kit has been finished
	fcs.msgHereIsFinishedKit(kit);

	// Now there should be one finished Kit in its list of kits
	EXPECT_EQ(1, fcs.getKits()->size());

	// The Kit's status should be FINISHED
	EXPECT_EQ(fcs.FINISHED, fcs.getKits()->front()->state);

	// Pick and Execute an Action should still return false because the FCS doesn't do anything with FINISHED kits yet
	EXPECT_FALSE(fcs.pickAndExecuteAnAction());
}